<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <div id="app">
    <input type="text" v-model='val' @keyup.enter='handle'>
    <!-- .enter 按键修饰符  用来监听回车 -->
    <input type="text" v-model='val' @keyup.delete='handle1'>
    <!-- .enter 按键修饰符  用来监听删除 按键删除 -->
    <input type="text" v-model='val' @keyup.q='handle2'>
    <input type="text" v-model='sha' @keyup='handle3'>
    <input type="text">
  </div>
  <script src="../vue.js"></script>
  <script>
    // 自定义按键修饰符 固定格式 Vue.config.keyCode.自定义名称= 按键键值
    Vue.config.keyCodes.q = 81
    var vm = new Vue({
      el: '#app',
      data: {
        val: '',
        sha: ''
      },
      methods: {
        handle() {
          console.log(this.val);
        },
        handle1() {
          this.val = ''
        },
        handle2() {
          console.log('成功');
        },
        handle3(event) {
          console.log(event.keyCode);

        }
      }
    })
  </script>
</body>

</html>